const mongoose=require('mongoose');
const { modelName,getAllexercisesModel } = require('../models/exercisesModel');


async function getAllexercises(req,res){
   let result= await getAllexercisesModel();
   if(result){
    res.send({
        code: 1,
        message: '所有题目信息获取成功',
        result: result

    });
}else{
    res.send({
        code: 0,
        message: '所有题目信息获取失败'
    })
}
}

async function getOneTitle(req,res){
    let result=await mongoose.model(modelName).find({...req.parmas}).populate('pointId');
    if(result){
        res.send({
            code: 1,
            message: '单个题目信息获取成功',
            result: result

        });
    }else{
        res.send({
            code: 0,
            message: '单个题目信息获取失败'
        })
    }
}


module.exports={
    getAllexercises,
    getOneTitle,
}